export default (arr, key) => {
    return arr
        .reduce((result, item) => {
            if (result.indexOf(item[key]) < 0) {
                result.push(item[key]);
            }
            return result;
        }, [])
        .reduce((result, keys) => {
            const children = arr.filter(item => item[key] === keys);
            result = result.concat(
                children.map((item, index) => ({
                    ...item,
                    [`${key}RowSpan`]: index === 0 ? children.length : 0,
                })),
            );
            return result;
        }, []);
};
